import { createStore } from 'vuex'
import persistedstate from 'vuex-persistedstate'
export default createStore({
    state: {
        isLogin: false, //默认没有登录
        actionSheetConfig: {
            isShow: false,
            list: [],
            successCallBack: null
        },
        userInfo: null,
        token: null

    },
    getters: {},
    mutations: {
        //这里应该还要写 登录、退出登录来改变isLogin
        login(state) {
            state.isLogin = true;
        },
        loginOut(state) {
            state.isLogin = false
            state.userInfo = null;
            state.token = null
        },
        showActionSheet(state, config) {
            state.actionSheetConfig.isShow = true;
            state.actionSheetConfig.list = config.list;
            state.actionSheetConfig.successCallBack = config.success
        },
        hideActionSheet(state) {
            state.actionSheetConfig.isShow = false;
            state.actionSheetConfig.list = []
            state.actionSheetConfig.successCallBack = null
        },
        setUserInfo(state, data) {
            state.userInfo = data
        },
        setToken(state, token) {
            state.token = token
        }
    },
    actions: {},
    modules: {},

    plugins: [persistedstate({
        storage: window.sessionStorage
    })]
})